package com.konsung.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.konsung.service.AutoUploadService;
import com.konsung.util.BroadcastUtils;

/**
 * 类功能：注册广播，监听自动上传
 */

public class AutoUploadReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent != null && intent.getAction() != null) {
            String action = intent.getAction();
            //监听登陆成功，启动自动上传服务
            if (action.equals(BroadcastUtils.ON_LOGIN_SUCCESS)) {
                Intent autoUploadIntent = new Intent(context, AutoUploadService.class);
                context.startService(autoUploadIntent);
            }
            if (action.equals(BroadcastUtils.START_AUTOUP_SERVICE)) {
                Intent autoUploadIntent = new Intent(context, AutoUploadService.class);
                context.startService(autoUploadIntent);
            }
        }
    }
}
